home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ptimer13.zip / PTIMER13.ASM < prev    next >
Assembly Source File  |  1991-02-19  |  46KB  |  1,061 lines

  1. ;
  2. TITLE   PTIMER.ASM
  3. ;
  4. COMMENT *
  5.         Purpose:        Times and logs external file-transfer protocols.
  6.  
  7.         Created:        15-APR-1989     V1.00   Richard B. Johnson
  8.  
  9.         Modified:       20-APR-1989     V1.01   Richard B. Johnson
  10.         Because of numerous complaints that the timing accuracy  was
  11.         not sufficient (it could be off 45 seconds/day). The timer code
  12.         was changed to use the MS-DOS clock so that the timing reflects
  13.         exactly what MS-DOS says. This should be accurate enough because
  14.         this is the time to which the PTIMER time was being compared.
  15.         Now it "looks" 100 percent accurate.
  16.  
  17.         Modified:       23-APR-1989     V1.02   Richard B. Johnson
  18.         Fixed bug in timing routine (typo) when I subtracted 23 hours
  19.         for a day rather than 24. Re-wrote time-code to make the day-
  20.         rollover correction more obvious.
  21.  
  22.         Modified:       05-AUG-1989     V1.03   Richard B. Johnson
  23.         Revised baud-rate search routine to properly read the WILDCAT!
  24.         ACTIVITY.LOG because revisions were made by WC! 2.0.
  25. -------------------------------------------------------------------------------
  26.         Users Note:  Found this excellent program on Richards BBS and
  27.         found it serves as a supurb timer for external protocols with
  28.         Telix.  Will no doubt work well with other communications
  29.         programs. Included in this archive are example batch files
  30.         for Telix.  Modify them to meet your own needs. Line 979 of Dick's
  31.         code may be changed to reflect "your" download directory i.e. Telix,
  32.         QModem and so on.  The compiled PTIMER13.COM in this archive is set
  33.         to record transfer results in C:\TELIX\PROTOCOL.LOG  - This is a fine
  34.         utility, enjoy it and drop Dick a note!.     Best Regards,
  35.                                                      John V.  02/18/91
  36.  
  37. *
  38. IF1
  39.       %OUT [PASS1]
  40. ELSE
  41.       %OUT [PASS2]
  42. ENDIF
  43.  
  44. VERS    STRUC
  45.         DB      'V1.03'                 ; Set version number here.
  46. VERS    ENDS
  47. ;
  48. ;       Structure of the data returned from the DOS "find-first" function
  49. ;       used to obtain file characteristics.
  50. ;
  51. FIL_BUF STRUC
  52. RESV    DB      21 DUP (?)
  53. ATTR    DB      ?                       ; Attribute
  54. FTIM    DW      ?                       ; Time
  55. FDAT    DW      ?                       ; Date
  56. SIZL    DW      ?                       ; Size-low
  57. SIZH    DW      ?                       ; Size-high
  58. PNAME   DB      13 DUP (?)              ; Packed name
  59. FIL_BUF ENDS
  60. ;
  61. ;       Structure of the BIOS segment.
  62. ;
  63. BIOS    SEGMENT AT 40H
  64. COM1    DW      ?                       ; Base address of 1st 8250 UART
  65. COM2    DW      ?                       ; Base address of 2nd 8250 UART
  66. COM3    DW      ?                       ; Base address of 3rd 8250 UART
  67. COM4    DW      ?                       ; Base address of 4th 8250 UART
  68. PRN1    DW      ?                       ; Base address of printer ports
  69. PRN2    DW      ?
  70. PRN3    DW      ?
  71. PRN4    DW      ?
  72.         ORG     06CH
  73. TICKL   DW      ?                       ; Low word of timer-tick
  74. TICKH   DW      ?                       ; High word of timer-tick
  75.         ORG     0F0H
  76. ICA     LABEL   BYTE                    ; Inter-process communication area
  77. RES1    DW      ?
  78. RES2    DW      ?
  79. RES3    DW      ?
  80. CX_SAV  DW      ?                       ; Saved hours/minutes
  81. DX_SAV  DW      ?                       ; Saved seconds
  82. BIOS    ENDS
  83. ;
  84. ;       Misc. equates.
  85. ;
  86. CR      EQU     0DH
  87. LF      EQU     0AH
  88. MS_DOS  EQU     21H                     ; Operating system
  89. FBUF    EQU     80H                     ; Default file-buffer
  90. ;
  91. PSEG    SEGMENT PARA PUBLIC 'CODE'
  92.         ASSUME CS:PSEG, DS:PSEG, ES:PSEG, SS:NOTHING
  93. START   EQU     $
  94.         ORG     100H
  95. MAIN    PROC    NEAR
  96.         MOV     SP,OFFSET STACK         ; Put in a safe place
  97. ;
  98. ;       Immediately get the system time, extract any old time,
  99. ;       and save the new value in the ICA.
  100. ;
  101.         MOV     AX,2C00H                ; Get the time
  102.         INT     MS_DOS                  ; From DOS
  103.         MOV     WORD PTR [NEW_CX],CX    ; Save the new time locally
  104.         MOV     WORD PTR [NEW_DX],DX    ;  seconds/hundredths
  105.  
  106.         PUSH    DS                      ; Save the segment
  107.         MOV     AX,BIOS                 ; Pick up BIOS segment
  108.         MOV     DS,AX                   ; Set segment
  109.         ASSUME  DS:BIOS                 ; Tell assembler
  110.         MOV     AX,WORD PTR [CX_SAV]    ; Pick up old time
  111.         MOV     BX,WORD PTR [DX_SAV]    ;   seconds/hundredths
  112.         MOV     WORD PTR [CX_SAV],CX    ; Save new values
  113.         MOV     WORD PTR [DX_SAV],DX    ;   seconds/hundreds
  114.         POP     DS                      ; Restore segment
  115.         ASSUME  DS:PSEG                 ; Tell the assembler
  116.         MOV     WORD PTR [OLD_CX],AX    ; Save old time hour/minutes
  117.         MOV     WORD PTR [OLD_DX],BX    ; Save old time seconds/tenths
  118. ;
  119. ;       Map the required command-line to upper case and extract the
  120. ;       string length.
  121. ;
  122.         CALL    MAP_CMD                 ; Map the command-line
  123.         TEST    CX,CX                   ; Check for anything typed
  124.         JNZ     CMD_OK                  ; Was okay
  125.         MOV     DX,OFFSET USAGE         ; Point to usage prompt
  126.         CALL    PROMPT                  ; Write to screen
  127.         JMP     FINIS                   ; Exit
  128. CMD_OK: PUSH    CX                      ; Save characters typed
  129.         CALL    WHEN                    ; Get data/time
  130.         POP     CX                      ; Restore characters typed
  131.         CALL    CHK_CMD                 ; Check commands, extract parameters
  132.         MOV     DI,WORD PTR [STR_ADDR]  ; Get addr. of string we are building
  133.         MOV     SI,OFFSET PRP5          ; The baud-rate
  134.         CALL    COPY
  135.         MOV     AX,WORD PTR [RATE]      ; Pick up the rate
  136.         XOR     DX,DX                   ; Zero high word
  137.         CALL    ASCII                   ; Convert to ASCII
  138. ;
  139. ;       Calculate the time in seconds from the values contained in:
  140. ;       OLD_CX =  [hour] [minutes]              of the starting time.
  141. ;       OLD_DX =  [seconds] [hundredths]        of the starting time.
  142. ;       NEW_CX =  [hour] [minutes]              of the ending time.
  143. ;       NEW_DX =  [seconds] [hundredths]        of the ending time
  144. ;
  145. ;       To do this accurately, we will convert the ending time of
  146. ;       hh:mm:ss to seconds. Then we will convert the starting time of
  147. ;       hh:mm:ss to seconds. We will then subtract the two. If midnight
  148. ;       has occurred, we will adjust accordingly.
  149. ;
  150.         MOV     AX,WORD PTR [NEW_DX]    ; AH = secs, AL = tenths
  151.         MOV     AL,AH                   ; Get seconds
  152.         XOR     AH,AH                   ; Remove tenths
  153.         MOV     WORD PTR [SEC_LO],AX    ; Save the new seconds
  154.         MOV     WORD PTR [SEC_HI],0     ; Zero the high word
  155.         MOV     AX,WORD PTR [NEW_CX]    ; Get new hours/minutes
  156.         MOV     BX,AX                   ; Save
  157.         XOR     AH,AH                   ; Remove hours, keep minutes
  158.         MOV     CX,60                   ; Seconds/minute
  159.         MUL     CX                      ; AX = minutes * 60
  160.         ADD     WORD PTR [SEC_LO],AX    ; Add to accumulator
  161.         ADC     WORD PTR [SEC_HI],0     ; Take care of overflow
  162.         MOV     CX,WORD PTR [OLD_CX]    ; Get old hours/minutes
  163.         CMP     BH,CH                   ; BH = new CH = old
  164.         JNC     DAY_OK                  ; Not a new day
  165.         ADD     BH,24                   ; compensate for new day
  166. ;
  167. DAY_OK: MOV     AL,BH                   ; Get hours
  168.         XOR     AH,AH                   ; Remove high byte
  169.         MOV     CX,3600                 ; Seconds/hour
  170.         MUL     CX                      ; DX:AX = seconds
  171.         ADD     WORD PTR [SEC_LO],AX    ; Add to the accumulator
  172.         ADC     WORD PTR [SEC_HI],DX    ; Add the high word
  173. ;
  174.         MOV     AX,WORD PTR [OLD_DX]    ; AH = secs, AL = tenths
  175.         MOV     AL,AH                   ; Get seconds
  176.         XOR     AH